import userOption from "@/option/sys/userOption";
import userApi from "@/api/sys/userApi";
import optionUtils from "@/option/optionUtils";
import {baseUrl} from "@/config/env";

export default () => {
    return {
        index: true,
        submitText: '修改',
        size: 'small',
        labelWidth: 120,
        menuType: 'menu',
        menuAlign: 'center',
        menuPosition: "right",
        addBtn: false,
        delBtn: false,
        editBtn: false,
        column: [
            {
                label: '任务id',
                span: 12,
                prop: 'id',
                hide: true,
            },
            {
                label: '任务定义key',
                prop: 'taskDefinitionKey',
                span: 12,
                hide: true,
            },
            {
                label: '流程名称',
                prop: 'modelName',
                span: 12,
            },
            {
                label: '流程类别',
                prop: 'modelCategory',
                span: 12,
                type: "select",
                dicUrl: baseUrl + "/sysDictionaryItem/listByDictionaryCode",
                dicMethod: "get",
                dicQuery: {code: "activiti_group"},
                props: {
                    label: 'name',
                    value: 'code',
                },
            },
            {
                label: '任务名称',
                prop: 'taskName',
                span: 12,
                rules: [{
                    required: true,
                    trigger: "blur"
                }]
            },
            {
                label: '任务类型',
                prop: 'taskType',
                span: 12,
                type: "select",
                dicData: [
                    {label: "个人任务", value: "user"},
                    {label: "组任务", value: "group"},
                ]
            },
            {
                label: '发起人',
                span: 12,
                prop: 'startUserId',
                type: "table",
                onLoad: (onLoadParams, callback) => {
                    onLoadParams.pageDefinition = userApi.list
                    onLoadParams.valueDefinition = userApi.getUserInfo
                    onLoadParams.option = userOption;
                    optionUtils.tableOnLoad(onLoadParams, callback)
                },
                formatter: (row) => {
                    if (!row) return;
                    if (row.nickName) {
                        return row.nickName;
                    } else if (row.realName) {
                        return row.realName
                    }
                    return row.userName;
                }
            },
            {
                label: '任务处理人',
                prop: 'assignee',
                span: 12,
                type: "table",
                children: userOption(),
                props: {
                    label: 'userName',
                    value: 'id'
                },
                onLoad: (onLoadParams, callback) => {
                    onLoadParams.pageDefinition = userApi.list
                    onLoadParams.valueDefinition = userApi.getUserInfo
                    onLoadParams.option = userOption;
                    optionUtils.tableOnLoad(onLoadParams, callback)
                },
                formatter: (row) => {
                    if (!row) return;
                    if (row.nickName) {
                        return row.nickName;
                    } else if (row.realName) {
                        return row.realName
                    }
                    return row.userName;
                }
            },
            {
                label: '任务优先级',
                prop: 'priority',
                span: 12,
                type: "number"
            },


            {
                label: '任务创建时间',
                prop: 'createTime',
                span: 12,
                type: 'datetime',
                valueFormat: 'yyyy-MM-dd HH:mm:ss',
                format: 'yyyy-MM-dd HH:mm:ss',
                editDisplay: false,
                addDisplay: false
            },

        ]
    }
}
